import request from './request'

export default {
  // 获取企业列表
  companyList (params) {
    return new Promise((resolve, reject) => {
      request.post('/company/companyList', params).then(res => {
        const { status, data: { eid, page, msg } } = res
        if (status === 200 && eid === 200) {
          resolve(page)
        } else {
          reject(msg)
        }
      })
    })
  },
  // 获取企业详情
  companyInfo (params) {
    return new Promise((resolve, reject) => {
      request.post('/company/companyInfo', params).then(res => {
        const { status, data: { eid, data, msg } } = res
        if (status === 200 && eid === 200) {
          resolve(data)
        } else {
          reject(msg)
        }
      })
    })
  },
  // 角色列表
  roleCompanyList (params) {
    return new Promise((resolve, reject) => {
      request.post('/role/roleCompanyList', params).then(res => {
        const { status, data: { eid, page, msg } } = res
        if (status === 200 && eid === 200) {
          resolve(page)
        } else {
          reject(msg)
        }
      })
    })
  },
  // 公司-菜单-树
  companyMenuTree (params) {
    return new Promise((resolve, reject) => {
      request.post('/companyMenuRef/companyMenuTree', params).then(res => {
        const { status, data: { eid, data, msg } } = res
        if (status === 200 && eid === 200) {
          resolve(data)
        } else {
          reject(msg)
        }
      })
    })
  }
}
